var a = require("../../../component/WxNotificationCenter/WxNotificationCenter.js"), t = getApp();

Page({
    data: {
        userAccessToken: "",
        dynamicTotal: -1,
        dynamics: [],
        pageNo: 1,
        isMy: !1
    },
    loadDynamicData: function(a) {
        var o = this, e = o.data.pageNo;
        if (a) e = 1; else if (o.data.dynamicTotal == o.data.dynamics.length) return void t.util.showToast("已加载完");
        t.network.post({
            url: t.url.listUserHomeWorkPage,
            params: {
                pageNo: e,
                pageSize: 20,
                userAccessToken: this.data.userAccessToken
            },
            before: function() {
                wx.showNavigationBarLoading();
            },
            success: function(n) {
                if (1 == n.data.result) {
                    var i;
                    a ? i = [] : o.data.dynamics, i = i.concat(n.data.data.dynamics), e += 1, o.setData({
                        dynamicTotal: n.data.data.total,
                        dynamics: i,
                        pageNo: e
                    });
                } else t.util.showToast(n.data.message);
            },
            fail: function() {
                t.util.showToast("获取数据失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading(), wx.setNavigationBarTitle({
                    title: "作品列表"
                });
            }
        });
    },
    refresh: function() {
        this.loadDynamicData(!0);
    },
    onLoad: function(o) {
        a.addNotification("DynamicMakeTopSuccess", this.refresh, this), this.setData({
            userAccessToken: o.userAccessToken,
            isMy: o.userAccessToken == t.globalData.accessToken
        });
    },
    onReady: function() {
        this.loadDynamicData(!0);
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {
        a.removeNotification("DynamicMakeTopSuccess", this);
    },
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.loadDynamicData(!1);
    },
    onShareAppMessage: function() {}
});